package View;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.ExecutionException;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;

import Controler.MonteCarloSimulation;
import Controler.Simulation;

public class MainWindow extends JFrame implements ActionListener{
	private static final long serialVersionUID = -8703843689450789725L;
	public JButton startStopButton;
	public JComboBox<String> comboBox;
	public JTextArea area;
	public JTextArea mArea;
	public Simulation simu;
	
	public void frameInit() {
		super.frameInit();
		getContentPane().setLayout(new FlowLayout());
		
		this.simu = new Simulation(this);
		
		startStopButton = new JButton("Start");
		
		String s[] = new String[5];
		s[0] = "1";
		s[1] = "2";
		s[2] = "3";
		s[3] = "4";
		s[4] = "5";
		comboBox = new JComboBox<>(s);
		
		area = new JTextArea();
		
		mArea = new JTextArea();
		
		getContentPane().add(comboBox);
		getContentPane().add(startStopButton);
		getContentPane().add(area);
		getContentPane().add(mArea);
		
		startStopButton.addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(startStopButton == (JButton) e.getSource()){
			try {
				this.simu.tourne(this.comboBox.getSelectedItem().toString());
			} catch (InterruptedException | ExecutionException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}

}
